package com.tsinghuabigdata.edu.ddmath.fragment;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.tsinghuabigdata.edu.ddmath.R;
import com.tsinghuabigdata.edu.ddmath.util.DensityUtils;
import com.tsinghuabigdata.edu.ddmath.util.WindowUtils;


/**
 * 豆豆课程
 * Created by Administrator on 2016/12/14.
 */

public class BeansEvaluateFragment extends MyBaseFragment {

    private static final String TAG = "sky";
    private Context   mContext;
    private ImageView mIvBuilding;


    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View root = inflater.inflate(R.layout.fragment_beans_evaluate, container, false);
        mIvBuilding = (ImageView) root.findViewById(R.id.iv_building);
        initView();
        return root;
    }

    private void initView() {
        mContext = getActivity();
        int screenHeight = WindowUtils.getScreenHeight(mContext);
        int statusBarHeight = WindowUtils.getStatusBarHeight(mContext);
        int bottomBarHeight = WindowUtils.getBottomBarHeight(mContext);
        int otherHeight = DensityUtils.dp2px(mContext, 25 / 2 + 50 + 200 + 60);
        int remainHeight = (screenHeight - statusBarHeight - bottomBarHeight) / 2 - otherHeight;
        Log.i(TAG, "remainHeight=" + remainHeight);
        if (remainHeight < 0) {
            LinearLayout.LayoutParams headParams = (LinearLayout.LayoutParams) mIvBuilding.getLayoutParams();
            int conHeight = (screenHeight - statusBarHeight - bottomBarHeight - DensityUtils.dp2px(mContext, 25)) / 2;
            Log.i(TAG, "conHeight=" + conHeight);
            int all = 100 + 200 + 60;
            headParams.width = conHeight * 450 / all;
            headParams.height = conHeight * 200 / all;
            mIvBuilding.setLayoutParams(headParams);
        }
    }

}
